<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <title>Vue示例</title>
</head>

<body>
<div id="app">
    <my-list :books="books">
        <!-- 作用域插槽也可以是具名的Slot -->
        <template scope="props" slot="book">
            <li>{{props.bookName}}</li>
        </template>
    </my-list>
</div>
<script charset="utf-8" src="../js/vue.min.js" type="text/javascript"></script>
<script type="text/javascript">
    Vue.component('my-list', {
        props: {
            books: {
                type: Array,
                default: function () {
                    return [];
                }
            }
        },
        template: '\
			<ul>\
				<slot name="book"\
					v-for="book in books"\
					:book-name="book.name">\
					<!-- 这里也可以写默认 slot 内容 -->\
				</slot>\
			</ul>'
    });

    var app = new Vue({
        el: '#app',
        data: {
            books: [
                {name: '《Vue.js实战》'},
                {name: '《JavaScript语言精粹》'},
                {name: '《JavaScript高级程序设计》'}
            ]
        }
    });
</script>
</body>

</html>